﻿@using MVCExtension.Points.Extensions
@using MVCExtension.Points.Models
@model MVCExtension.Points.Models.ProductListViewModel

@{
    ViewBag.Title = "Product list";
}

<h2>Product list using helper</h2>
<div class="row">
    <div class="col-md-6">@ShowProduct(Model.SportProducts, "list-group-item-info")</div>
    <div class="col-md-6">@ShowProduct(Model.BookProducts, "list-group-item-warning")</div>
</div>
<div class="row">
    <div class="col-md-6">@ShowProduct(Model.FoodProducts, "list-group-item-danger")</div>
</div>

<h2>Product list using htmlHelper</h2>
<div class="row">
    <div class="col-md-6">@Html.ListGroup().Info(Model.SportProducts,x=>x.Name)</div>
    <div class="col-md-6">@Html.ListGroup().Warning(Model.BookProducts,x => x.Name)</div>
</div>
<div class="row">
    <div class="col-md-6">@Html.ListGroup().Danger(Model.FoodProducts,x => x.Name)</div>
</div>


@helper ShowProduct(List<ProductListViewModel.Product> products, string style)
{
    <ul class="list-group">
        @foreach (var product in products)
        {
            <li class="list-group-item @style"><a href="@product.Href" target="_blank">@product.Name</a></li>
        }
    </ul>
}

